<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
    if(empty($id)){
        jumpajax('300','名厨(名店)不能为空!','');
    }
    $addDatalist=trim($_POST["addDatalist"]);
    $delDatalist=trim($_POST["delDatalist"]);
    if(!empty($addDatalist)){
        $addDatalisttemp=explode(",",$addDatalist);
        while(list($k,$v)=each($addDatalisttemp)){
            $v=trim($v);
            if(!empty($v)){
            $dlist=array("chefid"=>$id,"sdate"=>$v);
            $ezhand->insert("shopping3_schedule",$dlist);
            }   
        }        
    }

    if(!empty($delDatalist)){
        $delDatalisttemp=explode(",",$delDatalist);
        while(list($k,$v)=each($delDatalisttemp)){
            $v=trim($v);
            if(!empty($v)){
                $ezhand->delete("shopping3_schedule","chefid=".$id." and sdate='".$v."'");
            }   
        }        
    }
    jumpajax('200','排期设置成功','','closeCurrent');
   
}else{
	$id=empty($_REQUEST['id'])?0:(int)$_REQUEST['id'];
	$d=date("Y-m-d");
    if($id==0){
	    echo "请选择名店/名厨！";
        exit;  
	}else{
	    $row=$ezhand->select("shopping3_chef","*","id=".$id);
       
	    $datrow=$ezhand->select_all("shopping3_schedule",'*','chefid="'.$id.'" and orderid<=0');
	}
}
?>